<?php
declare (strict_types=1);

namespace app\api\controller;

use app\api\model\SystemLog;
use think\facade\Db;
use think\facade\View;


class Index extends Base
{
    public function index()
    {
        return view();
    }

    public function dataa()
    {
        $page = $this->request->param('page', 1);
        $res['code'] = 1;
        $res['msg'] = '';
        $res['data'] = SystemLog::order('create_time', 'desc')
            ->limit(($page - 1) * 2, 2)
            ->field('content,create_time')
            ->select()
            ->toArray();


        return json($res);
    }

    public function welcome()
    {

        $info['all_users'] = Db::name('user')->where('uid', session('admin.id'))->select()->count();
        $info['no_treat_withdraw'] = Db::name('user_draw_apply')->where('uid', session('admin.id'))->where('is_check', 0)->select()->count();
        $info['yesterday_orders'] = Db::name('user_tb_order')->where('uid', session('admin.id'))->whereDay('create_time', 'yesterday')->select()->count();
        $info['now_orders'] = Db::name('user_tb_order')->where('uid', session('admin.id'))->whereDay('create_time')->select()->count();
        //零时开始
        $tb['1']=Db::name('user_tb_order')->where('uid', session('admin.id'))->where('order_type', '淘宝')->whereDay('create_time', date('Y-m-d',strtotime('-6 day')))->select()->count();
        $tb['2']=Db::name('user_tb_order')->where('uid', session('admin.id'))->where('order_type', '淘宝')->whereDay('create_time', date('Y-m-d',strtotime('-5 day')))->select()->count();
        $tb['3']=Db::name('user_tb_order')->where('uid', session('admin.id'))->where('order_type', '淘宝')->whereDay('create_time', date('Y-m-d',strtotime('-4 day')))->select()->count();
        $tb['4']=Db::name('user_tb_order')->where('uid', session('admin.id'))->where('order_type', '淘宝')->whereDay('create_time', date('Y-m-d',strtotime('-3 day')))->select()->count();
        $tb['5']=Db::name('user_tb_order')->where('uid', session('admin.id'))->where('order_type', '淘宝')->whereDay('create_time', date('Y-m-d',strtotime('-2 day')))->select()->count();
        $tb['6']=Db::name('user_tb_order')->where('uid', session('admin.id'))->where('order_type', '淘宝')->whereDay('create_time', date('Y-m-d', strtotime('-1 day')))->select()->count();
        $tb['7']=Db::name('user_tb_order')->where('uid', session('admin.id'))->where('order_type', '淘宝')->whereDay('create_time', date('Y-m-d'))->select()->count();

        $pdd['1']=0;
        $pdd['2']=0;
        $pdd['3']=0;
        $pdd['4']=0;
        $pdd['5']=0;
        $pdd['6']=0;
        $pdd['7']=0;

        $jd['1']=0;
        $jd['2']=0;
        $jd['3']=0;
        $jd['4']=0;
        $jd['5']=0;
        $jd['6']=0;
        $jd['7']=0;

        //零时结束

        View::assign([
            'info' => $info,
            'tb' => $tb,
            'pdd' => $pdd,
            'jd' => $jd,
            'email' => 'thinkphp@qq.com'
        ]);
        return view();
    }

    public function iii()
    {
        return '（开发中........................）';
        $client = new \dtkapi\GetTipList();

        $client->setAppKey('60a9ea54efead');
        $client->setAppSecret('f0afa267225eb1c42887cc81e4ac06b3');
        $client->setVersion('v3.0.0');

        $res = $client->setParams([])->request();


        var_dump($res);


    }
}
